package com.wu.creditmanager;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.wu.creditmanager.db.BackupTask;
import com.wu.creditmanager.util.LayoutUtil;

public class MoreActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.credit_more);
		Resources res = getResources();
		LayoutUtil.initToolbar(findViewById(R.id.tbar),
				res.getString(R.string.about), null, null, null, null);
		findViewById(R.id.more_bt_backup).setOnClickListener(
				new OnClickListener() {
					public void onClick(View v) {
						new BackupTask(MoreActivity.this, true).execute();
					}
				});
		findViewById(R.id.more_bt_restore).setOnClickListener(
				new OnClickListener() {
					public void onClick(View v) {
						new AlertDialog.Builder(MoreActivity.this)
								.setIcon(R.drawable.icon)
								.setTitle(R.string.prompt)
								.setMessage(R.string.confirmRestore)
								.setPositiveButton(R.string.btn_OK,
										new DialogInterface.OnClickListener() {
											public void onClick(
													DialogInterface dialog,
													int whichButton) {
												dialog.dismiss();
												new BackupTask(
														MoreActivity.this,
														false).execute();
											}
										})
								.setNegativeButton(R.string.btn_CANCEL,
										new DialogInterface.OnClickListener() {
											public void onClick(
													DialogInterface dialog,
													int which) {
												dialog.dismiss();
											}
										}).create().show();
					}
				});
	}

}
